package id.laskarmedia.opnvpn_flutter.handler;

import java.util.HashMap;
import java.util.Map;

import id.laskarmedia.opnvpn_flutter.enums.VPNEventEnum;
import id.laskarmedia.opnvpn_flutter.handler.OC.ConnectEventHandler;
import id.laskarmedia.opnvpn_flutter.handler.OC.DisconnectEventHandler;
import id.laskarmedia.opnvpn_flutter.handler.OC.InitializeEventHandler;
import id.laskarmedia.opnvpn_flutter.handler.OC.PermissionEventHandler;
import id.laskarmedia.opnvpn_flutter.handler.OC.StateEventHandler;
import id.laskarmedia.opnvpn_flutter.handler.OC.StatusEventHandler;

/**
 * VPNEventManager is a class that manages VPN event handlers.
 */
public class VPNEventManager {
    private static Map<String, VPNEventHandler> eventHandlerMap = new HashMap<>();

    static {
        eventHandlerMap.put(VPNEventEnum.CONNECT.getMsg(), new ConnectEventHandler());
        eventHandlerMap.put(VPNEventEnum.DISCONNECT.getMsg(), new DisconnectEventHandler());
        eventHandlerMap.put(VPNEventEnum.INITIALIZE.getMsg(), new InitializeEventHandler());
        eventHandlerMap.put(VPNEventEnum.PERMISSION.getMsg(), new PermissionEventHandler());
        eventHandlerMap.put(VPNEventEnum.STATE.getMsg(), new StateEventHandler());
        eventHandlerMap.put(VPNEventEnum.STATUS.getMsg(), new StatusEventHandler());
    }

    /**
     * Retrieves the event handler for the specified VPN event.
     *
     * @param event The VPN event for which to retrieve the event handler.
     * @return The VPNEventHandler for the specified event, or null if not found.
     */
    public static VPNEventHandler getEventHandler(String event) {
        return eventHandlerMap.get(event);
    }
}
